﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace TD.TheGame 
{
    public class KeyBoardInput 
    {
        private KeyboardState newState;
        private KeyboardState oldState;

        public KeyBoardInput() 
        { 
        
        }

        public bool CheckKey(Keys key)
        {
            newState = Keyboard.GetState();
            if (Check(key))
            {
                oldState = newState;
                return true;
            }
            else
            {
                oldState = newState;
                return false;
            }
        }

        public bool Check(Keys key)
        {
            if (oldState.IsKeyDown(key) && newState.IsKeyUp(key))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
